#ifndef EVENT_H
#define	EVENT_H

#include "midifileapi.h"
#include <string>
#include <fstream>
#include "exceptions.h"

namespace MidiFile {

enum EventType {
    Invalid = 0x00,
    NoteOff = 0x80,
    NoteOn = 0x90,
    NoteAftertouch = 0xA0,
    Controller = 0xB0,
    ProgramChange = 0xC0, // 1 parametro
    ChannelAftertouch = 0xD0, // 1 parametro
    PitchBend = 0xE0,
    SysEx = 0xF0,
    SysExCont = 0xF7,
    Meta = 0xFF
};

enum MetaEventType {
    SequenceNumber = 0x0,
    Text = 0x1,
    CopyrightNotice = 0x2,
    SequenceName = 0x3,
    InstrumentName = 0x4,
    Lyrics = 0x5,
    Marker = 0x6,
    CuePoint = 0x7,
    OnChannelPrefix = 0x20,
    OnPortPrefix = 0x21,
    EndOfTrack = 0x2F,
    SetTempo = 0x51,
    SMTPOffset = 0x54,
    TimeSignature = 0x58,
    KeySignature = 0x59,
    SequencerSpecific = 0x7F
};

class MIDIFILE_DLL Event {
public:

    Event(EventType et = Invalid, int dt = 0) throw () : eventType(et), deltaTime(dt), midiChannel(0), parameter1(0), parameter2(0), metaEventType(SequenceNumber)
    {
    }
    Event(const Event &other) throw ();

    inline EventType getEventType() const throw ()
    {
        return eventType;
    }

    inline int getDeltaTime() const throw ()
    {
        return deltaTime;
    }

    char getMidiChannel() const throw (InvalidException);
    char getNoteNumber() const throw (InvalidException);
    char getVelocity() const throw (InvalidException);
    char getAmount() const throw (InvalidException);
    char getControllerType() const throw (InvalidException);
    char getControllerValue() const throw (InvalidException);
    char getProgramNumber() const throw (InvalidException);
    short getPitchBend() const throw (InvalidException);

    MetaEventType getMetaEventType() const throw (InvalidException);
    std::string getDataString() const throw (InvalidException);

    inline void setEventType(EventType value) throw ()
    {
        eventType = value;
    }

    inline void setDeltaTime(int value) throw ()
    {
        deltaTime = value;
    }

    void setMidiChannel(char value) throw (InvalidException);
    void setNoteNumber(char value) throw (InvalidException);
    void setVelocity(char value) throw (InvalidException);
    void setAmount(char value) throw (InvalidException);
    void setControllerType(char value) throw (InvalidException);
    void setControllerValue(char value) throw (InvalidException);
    void setProgramNumber(char value) throw (InvalidException);
    void setPitchBend(short value) throw (InvalidException);
    void setPitchBend(char param1, char param2) throw (InvalidException);

    void setMetaEventType(MetaEventType value) throw (InvalidException);
    void setData(const char *data, int length) throw (InvalidException);
    void setDataString(const std::string &value) throw (InvalidException);

private:
    EventType eventType;
    int deltaTime;

    char midiChannel;
    char parameter1;
    char parameter2;

    MetaEventType metaEventType;
    std::string strData;
};
}

#endif	/* EVENT_H */

